package com.test.webdemo.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

@Component
public class LifecycleBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.equals("fullLifecycleBean")) {
            System.out.println("【BeanPostProcessor】初始化前处理: " + beanName);
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.equals("fullLifecycleBean")) {
            System.out.println("【BeanPostProcessor】初始化后处理: " + beanName);
        }
        return bean;
    }
}
